package com.ynding.cloud.physical.magic.api.meta.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.ssssssss.magicapi.datasource.model.MagicDynamicDataSource;
import org.ssssssss.magicapi.modules.db.provider.PageProvider;

import javax.sql.DataSource;

/**
 * <p> </p>
 *
 * @author ynding
 * @version 2022/3/15
 **/
@Configuration
public class MagicAPIConfiguration {
    /**
     * 配置多数据源
     *
     * @see MagicDynamicDataSource
     */
    @Bean
    public MagicDynamicDataSource magicDynamicDataSource(DataSource dataSource) {
        MagicDynamicDataSource dynamicDataSource = new MagicDynamicDataSource();
        // 设置默认数据源
        dynamicDataSource.setDefault(dataSource);
        dynamicDataSource.add("slave", dataSource);
        return dynamicDataSource;
    }
}
